
import 'package:flutter/material.dart';
import 'package:myapp/app/theme/app_color.dart';

import 'app_tab_bar.dart';

typedef OnTabView = Widget Function(int);

class TabBarLayout extends DefaultTabController {

  TabBarLayout(List<String> tabs, OnTabView build, {PreferredSizeWidget? appBar}) : super(
    length: tabs.length,
    child: Scaffold(
      appBar: appBar,
      body: Flex(
        direction: Axis.vertical,
        children: [
          Container(child: AppTabBar(tabs), color: AppColor.white,),
          Expanded(
            child: TabBarView(
                children: tabs
                    .asMap()
                    .keys
                    .map((e) => build(e))
                    .toList()),
          ),
        ],
      ),
    ),
  );

}